package com.model;


public class MyTime {
	private int minute;
	private int hour;
	
	public MyTime(int hour,int minute){
		this.minute=minute;
		this.hour=hour;
	}
	
	public MyTime(String timeString){
		String[] tempTimes = timeString.split(":");
		this.hour = Integer.parseInt(tempTimes[0]);
		this.minute = Integer.parseInt(tempTimes[1]);
	}

	public String toString(){
		return hour+":"+minute;
	}
	
	
	public int getMinute() {
		return minute;
	}

	public void setMinute(int minute) {
		this.minute = minute;
	}

	public int getHour() {
		return hour;
	}

	public void setHour(int hour) {
		this.hour = hour;
	}
	
	/**
	 * 比较两个时间的大小
	 * @param time1
	 * @param time2
	 * @return 如果time1>time2，返回1；相等返回0；小于返回-1
	 */
	public static int compareTime(MyTime time1,MyTime time2){
		int temp1 = time1.getHour()*100+time1.getMinute();
		int temp2 = time2.getHour()*100+time2.getMinute();
		if (temp1>temp2)
			return 1;
		else if(temp1==temp2)
			return 0;
		else
			return -1;
	}
}
